﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：吕海乐 
    //
    // 文件名：RecieverSelect.aspx.cs
    // 文件功能描述：消息管理：选择收信人
    // 创建标识：吕海乐2009-5-20
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
// 审核时间：
// 审核说明：
 //----------------------------------------------------------------*/
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.Model;

namespace HZ.DrugTrade.Web.Hospitals.MessageMange
{
    public partial class RecieverSelect : BasePage
    {
        IBLL_Company ic = Factory.BLL_Company();
        IBLL_Hospital ih = Factory.BLL_Hospital();
        IBLL_ManageOrg im = Factory.BLL_ManageOrg();
        IBLL_Role ir = Factory.BLL_Role();

        protected void Page_Load(object sender, EventArgs e)
        {
            BindInfo();
        }

        /// <summary>
        /// 根据不同的flag绑定不同的内容
        /// </summary>
        private void BindInfo()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["flag"]))
            {
                //绑定医疗机构
                if (Request.QueryString["flag"] == "1")
                {
                    this.lblName.Text = "医疗机构名称：";
                    int totalCount;
                    //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
                    gvwHospital.Visible = true;
                    Model.Query.Hospital model = new HZ.DrugTrade.Model.Query.Hospital();
                    model.HospitalName = this.txtName.Text;
                    model.SortFields = "HospitalID";
                    IList<Hospital> lstHospital = ih.GetHospitalByWhere(model, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
                    //IList<Hospital> lstHospital = ih.GetHospitalByWhere(new Model.Query.Hospital() { SortFields = "HospitalID", HospitalName=this.txtName.Text}, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
                    AspNetPager1.RecordCount = totalCount;
                    gvwHospital.DataSource = lstHospital;
                    gvwHospital.DataBind();
                }
                //绑定企业
                if (Request.QueryString["flag"] == "2")
                {
                    this.lblName.Text = "企业名称：";
                    int totalCount;
                    //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
                    gvwCompany.Visible = true;
                    IList<Company> lstCompany = ic.GetCompanyByWhere(new Model.Query.Company() { SortFields = "CompanyID", CompanyName = this.txtName.Text }, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
                   
                    AspNetPager1.RecordCount = totalCount;
                    gvwCompany.DataSource = lstCompany;
                    gvwCompany.DataBind();
                }
                //绑定中心机构
                if (Request.QueryString["flag"] == "3")
                {
                    this.lblName.Visible = false;
                    this.txtName.Visible = false;
                    this.btnSearch.Visible = false;
                    gvwManageOrg.Visible = true;
                    IList<ManageOrg> lstManageOrg = im.GetAllManageOrg();
                    gvwManageOrg.DataSource = lstManageOrg;
                    gvwManageOrg.DataBind();
                }
                //绑定角色列表
                if (Request.QueryString["flag"] == "4")
                {
                    this.lblName.Visible = false;
                    this.txtName.Visible = false;
                    this.btnSearch.Visible = false;
                    int totalCount;
                    //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
                    gvwRole.Visible = true;
                    IList<Role> lstRole = ir.GetAllRole(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
                    AspNetPager1.RecordCount = totalCount;
                    gvwRole.DataSource = lstRole;
                    gvwRole.DataBind();
                }
            }
        }

        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            BindInfo();
        }
        /// <summary>
        /// 查询2009-11-14
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindInfo();
        }
    }
}
